package com.sz.service;

import com.alibaba.fastjson.JSON;
import com.sz.dao.IUserDao;
import com.sz.pojo.User;
import net.minidev.json.JSONValue;
import org.json.JSONObject;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Service;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayInputStream;
import java.io.ObjectInputStream;

@Service
public class RabbitmqConsumer {
    @Resource
    private IUserDao userDao;

    @RabbitListener(queues = {"ffms01"})
    public void receive(@Payload String newuser) throws Exception {
        User user = JSON.parseObject(newuser, User.class);
        userDao.addUser(user);
    }

}
